package com.hmall.search.controller;

import com.alibaba.fastjson.JSONObject;
import com.hmall.common.dto.PageDTO;
import com.hmall.common.dto.client.ItemClient;
import com.hmall.common.dto.pojo.Item;
import com.hmall.search.pojo.ItemDoc;
import com.hmall.search.pojo.RequestParms;
import com.hmall.search.service.SearchService;
import org.elasticsearch.action.bulk.BulkRequest;
import org.elasticsearch.action.bulk.BulkResponse;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.common.xcontent.XContentType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.List;

@RestController
@RequestMapping("/search")
public class SearchController {

    @Autowired
    ItemClient itemClient;

    @Autowired
    SearchService searchService;


    @GetMapping("/hi")
    public void h(){
        System.out.println(itemClient);
        System.out.println("hi");
    }

    @PostMapping("/list")
    public PageDTO<ItemDoc> pageSelcet(@RequestBody RequestParms params) throws IOException {
        return searchService.select(params);
    }


}
